package com.youlu.campus.admin.qa;

import com.youlu.campus.admin.annotation.AuthParamTypeEnum;
import com.youlu.campus.admin.annotation.RequestActivityAuth;
import com.youlu.campus.entity.ActivityQaRule;
import com.youlu.campus.entity.VO.req.ActivityQaRuleQueryVO;
import com.youlu.campus.service.activity.ActivityQaRuleService;
import com.yuelin.infrastructure.quantum.common.QResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class ActivityQaRuleController {
    @Autowired
    private ActivityQaRuleService activityQaRuleService;

    @PostMapping("/qa-rule/list")
    public QResult list(@RequestBody ActivityQaRuleQueryVO request) {
        return QResult.success(activityQaRuleService.list(request));
    }

    @PostMapping("/qa-rule/create")
    @RequestActivityAuth(activityId = "#request.activityQaInfoId",paramType = AuthParamTypeEnum.QA)
    public QResult create(@RequestBody ActivityQaRule request) {
        return QResult.success(activityQaRuleService.create(request));
    }

    @PostMapping("/qa-rule/update")
    @RequestActivityAuth(activityId = "#request.activityQaInfoId",paramType = AuthParamTypeEnum.QA)
    public QResult update(@RequestBody ActivityQaRule request) {
        return QResult.success(activityQaRuleService.update(request));
    }

    @GetMapping("/qa-rule/find-one")
    public QResult findOne(@RequestParam("id") String id) {
        return QResult.success(activityQaRuleService.findOne(id));
    }

    @GetMapping("/qa-rule/delete")
    @RequestActivityAuth(activityId = "#id",paramType = AuthParamTypeEnum.QA_RULE)
    public QResult delete(@RequestParam("id") String id) {
        return QResult.success(activityQaRuleService.delete(id));
    }
}
